package com.easy.modules.sysmgr.entity;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;

import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import com.easy.modules.common.RecordEntity;

@Entity
@Table(name = "EASY_SYSMGR_MENU")
@DynamicUpdate(true)
@DynamicInsert(true)
public class MenuEntity extends RecordEntity implements Serializable {

	private static final long serialVersionUID = 1L;
	
	private String name ;							//菜单名称
	
	private String href ;							//链接地址
	
	private String type ;							//菜单类型
	
	private String target ;							//目标（ mainFrame、_blank、_self、_parent、_top）
	
	private String action_value ;					//操作
	
	private String iconCls ;						//图标
	
	private Integer sort = new Integer(0) ;			//排序
		
	private String isShow = new String("1") ;		//是否显示（1：显示、0：不显示）
	
	private String state ;							//EasyUI Tree state("close,open")
	
	private String permitCode ;						//权限代码
	
	private String remark ;							//备注
	
	private MenuEntity menu ;
	
	private Set<MenuEntity> menus = new HashSet<MenuEntity>(0) ;
	
	private Set<PermitsEntity> permits = new HashSet<PermitsEntity>(0) ;	//权限组
	
	@ManyToMany(fetch = FetchType.LAZY)
	@JoinTable(name = "EASY_SYSMGR_PERMITS_MENUS", joinColumns = { @JoinColumn(name = "MENU_ID", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "PERMITS_ID", nullable = false, updatable = false) })
	public Set<PermitsEntity> getPermits() {
		return permits;
	}

	public void setPermits(Set<PermitsEntity> permits) {
		this.permits = permits;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getHref() {
		return href;
	}

	public String getType() {
		return type;
	}

	public String getAction_value() {
		return action_value;
	}

	public void setAction_value(String action_value) {
		this.action_value = action_value;
	}

	public void setType(String type) {
		this.type = type;
	}

	public void setHref(String href) {
		this.href = href;
	}

	public String getTarget() {
		return target;
	}

	public void setTarget(String target) {
		this.target = target;
	}

	public String getIconCls() {
		return iconCls;
	}

	public void setIconCls(String iconCls) {
		this.iconCls = iconCls;
	}

	public Integer getSort() {
		return sort;
	}

	public void setSort(Integer sort) {
		this.sort = sort;
	}

	public String getIsShow() {
		return isShow;
	}

	public void setIsShow(String isShow) {
		this.isShow = isShow;
	}

	public String getState() {
		return state;
	}

	public void setState(String state) {
		this.state = state;
	}

	public String getPermitCode() {
		return permitCode;
	}

	public void setPermitCode(String permitCode) {
		this.permitCode = permitCode;
	}

	
	@OneToMany
	@JoinColumn(name="MENU_PID")
	@OrderBy("sort desc")
	public Set<MenuEntity> getMenus() {
		return menus;
	}

	public void setMenus(Set<MenuEntity> menus) {
		this.menus = menus;
	}

	@ManyToOne
	@JoinColumn(name="MENU_PID")
	public MenuEntity getMenu() {
		return menu;
	}

	public void setMenu(MenuEntity menu) {
		this.menu = menu;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}
	

}
